﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Demo01.Repsotories;
using WindowsFormsApp1.Models;
using WindowsFormsApp1.Respostories;
using WindowsFormsApp1.Utils;


namespace WindowsFormsApp1.Respostories
{
    public class CategoryRepostory
    {
        List<Category> list = new List<Category>();

        public static List<Category> GetCategories()
        { 
            List<Category> list = new List<Category>();

            SqlDataReader reader = null;
            try
            {
                reader = DBHelper.Query("SELECT DISTINCT SlaveId FROM THRecords ORDER BY SlaveId ASC");
                while (reader.Read())
                {
                    Category category = new Category
                    {
                        //Id = reader.GetInt32(0).ToString(),
                        SlaveId = reader.GetInt32(0).ToString()+"号仓库",
                        //Temperature = reader.GetDouble(1).ToString(),
                        //Humidity = reader.GetDouble(2).ToString(),
                        //Creation = reader.GetDateTime(3)
                    };
                    list.Add(category);
                }
            }
            finally
            {
                reader?.Close();
            }



            return list;

        }

    }
    
}
